package com.my.aslife.controller;

import com.my.aslife.module.common.ErrorCode;
import com.my.aslife.module.common.PageRequestVo;
import com.my.aslife.module.common.ResponseResult;
import com.my.aslife.module.entity.dtos.ConsultCommitDto;
import com.my.aslife.service.ConsultService;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author mayuan
 * @description TODO
 */
@RestController
@RequestMapping("/api/my/consult")
@Slf4j
public class ConsultController {

    @Autowired
    private ConsultService consultService;


    @PostMapping("/commit/consult")
    public ResponseResult commitConsult(@RequestBody ConsultCommitDto consultCommitDto){
        if (consultCommitDto.getUid() == null || consultCommitDto.getOrderId() == null) {
            return ResponseResult.failed(ErrorCode.C_PARAMS_NOT_NULL);
        }
        return consultService.commitConsult(consultCommitDto);
    }

    @GetMapping("/get/list")
    public ResponseResult selectOrderInfoByPageAndCondition(@RequestParam Integer current, @RequestParam Integer pageSize,
                                                            @RequestParam(value = "orderId", required = false) String orderId) {

        PageRequestVo pageRequestVo = new PageRequestVo(current, pageSize);

        return consultService.selectOrderInfoByPageOrCondition(pageRequestVo);
    }

    @PostMapping("/send/email/{id}")
    public ResponseResult sendEmail(@PathVariable Integer id){
        return consultService.sendEmail(id);
    }

}
